package ed.hbut.supermarket1.mapper;


import ed.hbut.supermarket1.dto.UpdatePasswordDto;
import ed.hbut.supermarket1.entity.Employee;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface EmpMapper {

    @Select("select * from employee ")
    List<Employee> getAllEmp();


    @Insert("insert into employee(EmployeeName,EmployeePhone,EmployeePosition,EmployeeSex,EmployeeAge,CreateTime,username,password) value (#{employeeName},#{employeePhone}," +
            "#{employeePosition},#{employeeSex},#{employeeAge},#{createTime},#{username},#{password})")
    void addEmp(Employee employee);


    @Update("update employee set EmployeeName=#{employeeName},EmployeeAge=#{employeeAge},EmployeeSex=#{employeeSex},EmployeePosition=#{employeePosition}," +
            "EmployeePhone=#{employeePhone} where EmployeeID=#{employeeID}")
    void updateEmp(Employee employee);


    @Delete("delete from employee where EmployeeID =#{id}")
    void deleteEmp(int id);

    @Select("select * from employee where EmployeeID=#{id}")
    Employee getById(int id);

    @Select("select employee.password from employee where username=#{username}")
    String login(String username);

    @Select("select * from  employee where username=#{username}")
    Employee getByUsername(String username);


    @Update("update employee set password=#{password}  where username=#{username}")
    void updatePassword(UpdatePasswordDto updatePasswordDto);
}
